<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get last Java exception</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.java-last-exception-clear.html">java_last_exception_clear</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="book.ldap.html">LDAP</a></div>
 <div class="up"><a href="ref.java.html">Java 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.java-last-exception-get" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">java_last_exception_get</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.2)</p><p class="refpurpose"><span class="refname">java_last_exception_get</span> &mdash; <span class="dc-title">Get last Java exception</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.java-last-exception-get-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">object</span> <span class="methodname"><strong>java_last_exception_get</strong></span>
    ( <span class="methodparam">void</span>
   )</div>

  <p class="para rdfs-comment">
   Gets last Java exception.
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.java-last-exception-get-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns an exception object.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.java-last-exception-get-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   The following example demonstrates the usage of Java&#039;s exception
   handler from within PHP:
   <div class="example" id="example-4292">
    <p><strong>Example #1 Java exception handler</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$stack&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Java</span><span style="color: #007700">(</span><span style="color: #DD0000">'java.util.Stack'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$stack</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">push</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;This&nbsp;should&nbsp;succeed<br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$stack</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">pop</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$ex&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">java_last_exception_get</span><span style="color: #007700">();<br />if&nbsp;(!</span><span style="color: #0000BB">$ex</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$result</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">//&nbsp;This&nbsp;should&nbsp;fail&nbsp;(error&nbsp;suppressed&nbsp;by&nbsp;@)<br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;@</span><span style="color: #0000BB">$stack</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">pop</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$ex&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">java_last_exception_get</span><span style="color: #007700">();<br />if&nbsp;(</span><span style="color: #0000BB">$ex</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$ex</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">toString</span><span style="color: #007700">();<br />}<br /><br /></span><span style="color: #FF8000">//&nbsp;Clear&nbsp;last&nbsp;exception<br /></span><span style="color: #0000BB">java_last_exception_clear</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.java-last-exception-get-notes">
  <h3 class="title">注释</h3>
  <div class="warning"><strong class="warning">Warning</strong><p class="simpara">此函数是<em class="emphasis">实验性</em>的。此函数的表象，包括名称及其相关文档都可能在未来的
PHP 发布版本中未通知就被修改。使用本函数风险自担 。</p></div>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.java-last-exception-clear.html">java_last_exception_clear</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="book.ldap.html">LDAP</a></div>
 <div class="up"><a href="ref.java.html">Java 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
